home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 6 / develop 6 code / TCP / NewsWatcher / NewsWatcher 2.0d15 source / source / glob.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-30  |  12.4 KB  |  308 lines  |  [TEXT/KAHL]

  1. /* Constants. */
  2.  
  3. #define CR            '\r'
  4. #define LF            '\n'
  5. #define    CRSTR        "\r"
  6. #define    LFSTR        "\n"
  7. #define CRLF        "\r\n"
  8. #define CRCR         "\r\r"
  9.  
  10. #define homeKey                0x01        /* ascii code for home key */
  11. #define enterKey            0x03        /* ascii code for enter key */
  12. #define endKey                0x04        /* ascii code for end key */
  13. #define helpKey                0x05        /* ascii code for help key */
  14. #define deleteKey            0x08        /* ascii code for delete/backspace */
  15. #define tabKey                0x09        /* ascii code for tab key */
  16. #define pageUpKey            0x0B        /* ascii code for page up key */
  17. #define pageDownKey            0x0C        /* ascii code for page down key */
  18. #define returnKey            0x0D        /* ascii code for return key */
  19. #define leftArrow            0x1C        /* ascii code for left arrow key */
  20. #define rightArrow            0x1D        /* ascii code for right arrow key */
  21. #define upArrow                0x1E        /* ascii code for up arrow key */
  22. #define downArrow            0x1F        /* ascii code for down arrow key */
  23. #define forwardDelKey        0x7F        /* ascii code for forward delete key */
  24.  
  25. #define escapeKeyCode        0x35        /* key code for escape key */
  26. #define clearKeyCode        0x47        /* key code for clear key */
  27.  
  28. #define kVScroll            0            /* refcon for vertical scroll bars */
  29. #define kHScroll            1            /* refcon for horizontal scroll bars */
  30. #define kSendButton            2            /* refcon for send button control */
  31.  
  32. #define kLDEFProc            128
  33.  
  34. #define kNNTPPort            119
  35. #define kSMTPPort            25
  36. #define kFTPPort            21
  37.  
  38. #define kBufLen                0x7fff        /* buffer size for TCP stream send/receives (32K) */
  39. #define kMaxLength            32000        /* max length of article section */
  40.  
  41. #define kTextMargin            4
  42. #define kSectionMargin        120
  43.  
  44. #define kOffLeft            5
  45. #define kOffTop                41
  46. #define kDefaultWindHeight    230
  47. #define kMinWindHeight        64
  48. #define kMinWindWidth        200
  49.  
  50. #define kLifeBoatSize        40000L
  51.  
  52. #define kFCreator            'NNTP'
  53. #define kFType                'NEWS'
  54. #define kPrefType            'PREF'
  55.  
  56. #define kPrefName            "\pNewsWatcher Preferences"
  57. #define kOldPrefName        "\pNews Prefs"
  58. #define kFilterName            "\pNewsWatcher Filters"
  59. #define kShowText            "\pShow Full Group List"
  60. #define kHideText            "\pHide Full Group List"
  61.  
  62. #define kTPrefRecSize        7960
  63.  
  64.  
  65. /* Types. */
  66.  
  67. typedef char CStr255[256];        /* like Str255, except for C-format strings. */
  68.  
  69. typedef enum EWindowKind {
  70.     kFullGroup,                    /* full group list window */
  71.     kNewGroup,                    /* new groups list window */
  72.     kUserGroup,                    /* user group list window */
  73.     kSubject,                    /* subject list window */
  74.     kArticle,                    /* article window */
  75.     kMiscArticle,                /* misc article window (no parent subject window) */
  76.     kMailMessage,                /* mail message window */
  77.     kPostMessage,                /* posting message window */
  78.     kStatus                        /* status window */
  79. } EWindowKind;
  80.  
  81. typedef enum EMatchType { 
  82.     kContains,                     /* string contains another string */
  83.     kStartsWith,                 /* string starts with another string */
  84.     kEquals                     /* string equals another string */
  85. } EMatchType;
  86.  
  87. typedef struct THeader {
  88.     long number;                /* article number */
  89.     long offset;                /* offset in strings of header text */
  90. } THeader;
  91.  
  92. typedef struct TUnread {
  93.     long firstUnread;            /* first unread message */
  94.     long lastUnread;            /* last unread message */
  95.     struct TUnread **next;        /* handle to next entry in list */
  96. } TUnread;
  97.  
  98. typedef struct TGroup {
  99.     long nameOffset;            /* offset in gGroupNames of group name string */
  100.     long firstMess;                /* # of first msg in group */
  101.     long lastMess;                /* # of last msg in group */
  102.     TUnread **unread;            /* handle to list of unread messages for group */
  103.     long numUnread;                /* number of unread articles in group */
  104.     char status;                /* a general purpose status "marker" used in
  105.                                    several contexts */
  106.     Boolean onlyRedrawCount;    /* true to tell LDEF to only redraw the unread
  107.                                    message count */
  108. } TGroup;
  109.  
  110. typedef struct TSubject {
  111.     long subjectOffset;            /* offset in strings block of subject string */
  112.     long authorOffset;            /* offset in strings block of author string */
  113.     long number;                /* article number */
  114.     long threadHeadNumber;        /* article number of first article in thread  */
  115.     short myIndex;                /* index of self in subject array */
  116.     short threadHeadIndex;        /* index of first article in thread in
  117.                                    subject array. */
  118.     short threadOrdinal;        /* article ordinal in thread (1,2,3,...) */
  119.     short threadLength;            /* total number of articles in thread */
  120.     short nextInThread;            /* index in subject array of next subject 
  121.                                    in this thread, or -1 if none. */
  122.     Boolean collapsed;            /* true if thread collapsed */
  123.     Boolean read;                /* true if article has been read */
  124.     Boolean drawTriangleFilled;    /* true to tell LDEF to draw triangle filled with 
  125.                                    black. */
  126.     Boolean onlyRedrawTriangle;    /* true to tell LDEF to only redraw the
  127.                                    triangle */
  128.     Boolean onlyRedrawCheck;    /* true to tell LDEF to only redraw the √ */
  129.     short highlight;            /* nonzero: index of highlight color */
  130. } TSubject;
  131.  
  132. typedef struct TChild {
  133.     WindowPtr childWindow;        /* pointer to child window */
  134.     struct TChild **next;        /* handle to next entry in list */
  135. } TChild;
  136.  
  137. typedef struct TWindow {
  138.     EWindowKind kind;            /* kind of window */
  139.     ListHandle theList;            /* list handle */
  140.     TEHandle theTE;                /* TextEdit handle */
  141.     TGroup **groupArray;        /* handle to group array */
  142.     short numGroups;            /* number of groups */
  143.     Handle unsubscribed;        /* handle to list of unsubscribed groups if user
  144.                                    group list, or nil if none */
  145.     TSubject **subjectArray;    /* handle to subject array  */
  146.     short numSubjects;            /* number of subjects */
  147.     long firstFetched;            /* article number of first article fetched if
  148.                                    subject window */
  149.     long groupNameOffset;        /* offset in gGroupNames of group name if subject
  150.                                    window */
  151.     Handle strings;                /* handle to strings */
  152.     Handle fullText;            /* handle to full article text */
  153.     Handle headerText;            /* handle to header text for message window if
  154.                                    header not shown */
  155.     short numSections;            /* number of sections */
  156.     short curSection;            /* current section */
  157.     long **sectionBreaks;        /* handle to array of section breaks */
  158.     Handle msgId;                /* handle to msgId if misc article window */
  159.     FSSpec theFile;                /* saved disk file */
  160.     ScriptCode scriptTag;        /* script code for saved disk file */
  161.     WindowPtr parentWindow;        /* pointer to parent window */
  162.     short parentGroup;            /* index in groupArray of parent window for 
  163.                                    this subject window */
  164.     short parentSubject;        /* index in subjectArray of parent window for
  165.                                    this article window */
  166.     TChild **childList;            /* handle to linked list of child windows */
  167.     Boolean changed;            /* true if contents changed */
  168.     Boolean okToCloseIfChanged;    /* true if ok to close window with changes without saving */
  169.     Boolean saved;                /* true if contents saved */
  170.     Boolean autoFetched;        /* true if autofetched from host */
  171.     Boolean headerShown;        /* true if header shown in article or 
  172.                                    message window */
  173.     Boolean authorsShown;        /* true if authors shown in subject window */
  174.     short panelHeight;            /* height of panel area below window title bar
  175.                                    in article and message windows */
  176.     short groupNameHCoord;        /* h coord of group name in user group window */
  177.     short numUnreadHCoord;        /* h coord of num unread articles in
  178.                                    user group window */
  179.     short minusSignHCoord;        /* h coord of minus sign in subject window */
  180.     short threadCountHCoord;    /* h coord of thread count in subject window */
  181.     short checkHCoord;            /* h coord of √ in subject window */
  182.     short authorHCoord;            /* h coord of author in subject window */
  183.     short authorWidth;            /* width of author field in subject window */
  184.     short subjectHCoord;        /* h coord of subject in subject window */
  185.     PolyHandle expandTriangle;    /* handle to expanded triangle polygon */
  186.     PolyHandle collapseTriangle;/* handle to collapsed triangle polygon */
  187. } TWindow;
  188.  
  189. typedef struct TPrefRec {
  190.  
  191.     Str255    newsServerName;        /* name of news server */
  192.     Str255    textFont;            /* name of textedit font */
  193.     short    textSize;            /* size of textedit font */
  194.     Str255    listFont;            /* name of list font */
  195.     short    listSize;            /* size of list font */
  196.     Rect    groupWindowRect;    /* saved full group list window rect */
  197.     Point    unused1;            /* unused (used to be stagerring offset) */
  198.     Point    statusWindowLocn;    /* origin of status window */
  199.     short    maxFetch;            /* max. number of articles to fetch */
  200.     CStr255    name;                /* username */
  201.     CStr255    host;                /* user's host */
  202.     CStr255    fullName;            /* user's full name */
  203.     CStr255    organization;        /* user's organization */
  204.     char    signature[4096];    /* user's signature */
  205.     Boolean    groupWindowVisible;    /* true if group window is visible */
  206.     Boolean    unused4;            /* unused (used to be auto zoom windows) */
  207.     Boolean    unused2;            /* unused (used to be offset winds from parent) */
  208.     Boolean unused3;            /* unused (used to be most recent first) */
  209.     Str255    mailServerName;        /* mail server name */
  210.     CStr255    address;            /* user's e-mail address */
  211.     
  212.     /*     Added in 1.2(NU) */
  213.     char    magicCookie[12];    /* magic cookie */
  214.     char    version[12];        /* version string */
  215.     Boolean    areYouSureAlert;    /* true to present are you sure alert on 
  216.                                    postings */
  217.                                    
  218.     /*    Added in 1.3d1 */
  219.     Boolean    autoFetchnewsrc;    /* auto get/put .newsrc file */
  220.     Boolean replyCC;            /* replies CC sender */
  221.     
  222.     /*     Added in 1.3d4 */
  223.     Boolean showHeaders;        /* true to show headers by default */
  224.     Boolean showAuthors;        /* true to show authors in subject windows */
  225.     Boolean showThreadsCollapsed;    /* true to show threads collapsed by default */
  226.  
  227.     /* Added in 2.0d9 */
  228.     Boolean checkForNewGroups;    /* Check for new newsgroups at startup */
  229.     Boolean showKilledArticles;    /* Killed articles are shown but marked as read */
  230.     unsigned long groupCheckTime;    /* The last time we checked for new groups */
  231.     char    remotePassword[32];    /* Password for remote .newsrc put/get */
  232.     Boolean    savePassword;        /* Save password between sessions? */
  233.  
  234.     Boolean    expandHilited;         /* Expand threads with highlighted articles */
  235.  
  236.     OSType    textCreator;        /* Creator code for saved text files */
  237.     Str31    textCreatorName;    /* And the name of the app */
  238.     Str31    textVolName;        /* Volume to store saved text files */
  239.     long    textDirID;            /* and dirID */
  240.     short    maxGroupNameWidth;    /* max group name width in current list font
  241.                                    and size, or 0 if needs to be recomputed */
  242.     Boolean    useXPAT;            /* use XPAT for searching if available */
  243.     
  244.     /* Added in 2.0d10 */
  245.     Boolean textDefaultDir;        /* true if using default vol/dirID for saved text files */
  246.     char    remotePath[32];        /* .newsrc pathname for remote put/get */
  247.     
  248.     /* Added in 2.0d11 */
  249.     
  250.     Boolean    addSigSeparatorLine;/* true to add "-- " separator line before sig */
  251.     
  252.     /* Added in 2.0d12 */
  253.     
  254.     Boolean keypadShortcuts;    /* true if keypad shortcuts enabled */
  255.     Boolean logActionsToFile;    /* true if logging enabled */
  256.     
  257.     /* Added in 2.0d14 */
  258.     
  259.     Boolean batchedGroupCmds;    /* use batched GROUP commands */
  260.     Boolean noNewConnection;    /* don't establish new connection when checking for new articles */
  261.     Boolean noModeReader;        /* don't send MODE READER command */
  262.  
  263.     char    fill[1349];            /* for future expansion */
  264.     
  265. } TPrefRec, *TPrefPtr;
  266.  
  267. /* Global variables. */
  268.  
  269. extern short        gNumGroups;            /* number of newsgroups */
  270. extern TGroup        **gGroupArray;        /* handle to full group array */
  271. extern Handle        gGroupNames;        /* handle to group name strings */
  272. extern WindowPtr    gFullGroupWindow;    /* pointer to full group list window */
  273. extern Boolean        gMustDoZoomOnShowFullGroupList;
  274.                                         /* true if full group list needs zooming */
  275.  
  276. extern TPrefRec     gPrefs;                /* preferences */
  277.  
  278. extern Boolean        gDone;                /* flag set true upon program termination */
  279. extern Boolean         gCancel;            /* flag set when user cancels an action */
  280.  
  281. extern Handle        gLifeBoat;            /* lifeboat memory -- de-allocated when 
  282.                                            memory gets low */
  283. extern Boolean        gSinking;            /* flag set after lifeboat has been 
  284.                                            jettisoned */
  285. extern Boolean         gOutOfMemory;        /* flag set when out of memory - and luck */
  286.  
  287. extern Boolean        gInBackground;        /* background/foreground flag */
  288. extern Rect            gDesktopExtent;        /* desktop extent */
  289.  
  290. extern Cursor        gIBeamCurs;            /* ibeam cursor */
  291. extern Boolean        gHasColorQD;        /* true if we have color QuickDraw */
  292. extern Rect            gWindLimits;        /* window grow limits */
  293.  
  294. extern CStr255        gAutoFetchHost;        /* autofetch host */
  295. extern CStr255        gAutoFetchName;        /* autofetch username */
  296. extern char            gAutoFetchPass[32];    /* autofetch password */
  297. extern char            gAutoFetchPath[32];    /* autofetch path */
  298.  
  299. extern Rect            gDragRect;            /* drag limit rectangle */
  300.  
  301. extern Boolean        gStartingUp;        /* true during initialization */
  302. extern Boolean        gStartupOK;            /* true if no errors during startup */
  303.  
  304. extern Boolean        gFullGroupListDirty;    /* true if full group list dirty */
  305.  
  306. extern FSSpec         gPrefsFile;            /* preferences file location */
  307. extern FSSpec        gFilterFile;        /* filter file location */
  308.